:root{
  --bg:#f6f7f2;
  --paper:#ffffff;
  --ink:#18202a;
  --muted:#687382;
  --line:#dfe4dc;
  --soft:#edf1e8;
  --accent:#1f7a68;
  --accent-ink:#ffffff;
  --warn:#9a5b00;
  --shadow:0 10px 30px rgba(23,32,42,.10);
}

*{box-sizing:border-box}
html,body{min-height:100%}
body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font:15px/1.45 system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
}

.appbar{
  position:sticky;
  top:0;
  z-index:20;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:12px 14px;
  background:rgba(246,247,242,.94);
  border-bottom:1px solid var(--line);
  backdrop-filter:blur(10px);
}
.brand{font-size:18px;font-weight:800}
.caption{color:var(--muted);font-size:12px;margin-top:1px}

.shell{
  width:min(1120px,100%);
  margin:0 auto;
  padding:12px;
}

.playerPanel{
  position:sticky;
  top:64px;
  z-index:10;
  background:var(--paper);
  border:1px solid var(--line);
  border-radius:18px;
  overflow:hidden;
  box-shadow:var(--shadow);
}
.player{
  display:block;
  width:100%;
  aspect-ratio:16/9;
  max-height:58vh;
  background:#000;
}
.playerBody{padding:13px}
h1{
  margin:0;
  font-size:22px;
  line-height:1.15;
  letter-spacing:0;
}
p{margin:6px 0 0;color:var(--muted)}

.primaryActions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin-top:13px;
}
.action,.pill,.mini{
  border:1px solid var(--line);
  background:var(--paper);
  color:var(--ink);
  border-radius:14px;
  min-height:46px;
  padding:11px 14px;
  font:inherit;
  font-weight:750;
  text-align:center;
  text-decoration:none;
  cursor:pointer;
}
.action.primary{
  background:var(--accent);
  border-color:var(--accent);
  color:var(--accent-ink);
}
.action:hover,.pill:hover,.mini:hover{background:var(--soft)}
.action.primary:hover{background:#176756}
.primaryActions .action:last-child{grid-column:1/-1}

.details{
  margin-top:12px;
  border-top:1px solid var(--line);
  padding-top:10px;
}
summary{
  min-height:42px;
  display:flex;
  align-items:center;
  font-weight:750;
  cursor:pointer;
}
dl{
  display:grid;
  grid-template-columns:minmax(92px,.6fr) 1fr;
  gap:7px 12px;
  margin:4px 0 0;
}
dt{color:var(--muted)}
dd{margin:0;min-width:0;overflow-wrap:anywhere}
dd a{color:var(--accent);font-weight:700}

.toolbar{
  display:flex;
  gap:8px;
  margin:14px 0 10px;
}
.search{
  flex:1;
  width:100%;
  border:1px solid var(--line);
  border-radius:14px;
  background:var(--paper);
  color:var(--ink);
  min-height:48px;
  padding:11px 13px;
  font:inherit;
}
.mini{min-height:44px;padding:9px 12px}
.pill{min-width:98px}

.selectedTray{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin:0 0 10px;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:14px;
  background:var(--soft);
  font-weight:750;
}

.grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
  padding-bottom:24px;
}
.card{
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--paper);
  overflow:hidden;
  box-shadow:0 6px 18px rgba(23,32,42,.06);
}
.card.active{outline:3px solid rgba(31,122,104,.28)}
.thumb{
  position:relative;
  display:block;
  width:100%;
  aspect-ratio:16/9;
  border:0;
  padding:0;
  background:#d9dfd5;
  cursor:pointer;
  overflow:hidden;
}
.thumb img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}
.thumbFallback{
  height:100%;
  display:grid;
  place-items:center;
  color:var(--muted);
  font-weight:800;
}
.duration{
  position:absolute;
  right:7px;
  bottom:7px;
  border-radius:999px;
  padding:3px 7px;
  background:rgba(0,0,0,.72);
  color:#fff;
  font-size:12px;
  font-weight:800;
}
.cardBody{padding:10px}
.cardTitle{
  margin:0;
  font-size:15px;
  font-weight:850;
  line-height:1.2;
}
.cardMeta{
  margin-top:4px;
  color:var(--muted);
  font-size:12px;
}
.badges{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  margin-top:8px;
}
.badge{
  border:1px solid var(--line);
  border-radius:999px;
  padding:3px 7px;
  background:var(--soft);
  color:var(--muted);
  font-size:11px;
  font-weight:800;
}
.badge.warn{color:var(--warn)}
.cardActions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  margin-top:10px;
}
.cardActions button,.cardActions a{
  min-height:42px;
  border-radius:12px;
  border:1px solid var(--line);
  background:var(--paper);
  color:var(--ink);
  font:inherit;
  font-size:13px;
  font-weight:800;
  text-align:center;
  text-decoration:none;
  cursor:pointer;
  display:grid;
  place-items:center;
}
.cardActions .selected{
  background:var(--accent);
  border-color:var(--accent);
  color:#fff;
}

.toast{
  position:fixed;
  left:50%;
  bottom:18px;
  transform:translateX(-50%);
  z-index:40;
  max-width:min(92vw,420px);
  padding:11px 14px;
  border-radius:999px;
  background:#18202a;
  color:#fff;
  box-shadow:var(--shadow);
  font-weight:750;
}

@media (min-width:760px){
  .shell{
    display:grid;
    grid-template-columns:420px 1fr;
    gap:16px;
    align-items:start;
  }
  .playerPanel{
    grid-row:1 / span 4;
    top:78px;
  }
  .toolbar,.selectedTray,.grid{grid-column:2}
  .grid{grid-template-columns:repeat(3,minmax(0,1fr))}
}

@media (max-width:420px){
  .grid{gap:10px}
  .cardBody{padding:9px}
  .action,.pill,.mini,.search{border-radius:12px}
  h1{font-size:20px}
}
